#pragma once
#include "Light.h"
#include "Object.h"
#include "sampler.h"
#include <cfloat>

namespace mray{

	struct BaseSampler;
	struct Ray;

	struct AreaLight : public BaseLight, public Rectangle{
		AreaLight(const Rectangle& rect, BaseSampler* pSpl, const vec3& color, bool castShdow, bool visible);
		virtual ~AreaLight();

		virtual bool Hit(Ray& ray, Result* pResult = nullptr)const;
		virtual vec3 Illuminate(const Result& result)const;

	private:
		//default there is noly one sample set
		BaseSampler* m_spl;
		float PDF(const vec3& wi)const;
		Atten m_atten;
		bool m_visible;

		friend struct Parser;
	};

}